
import React from 'react'
import { List, Switch } from 'antd-mobile'
import { useNavigate, useSearchParams } from 'react-router-dom'
import { Button, Input, Form, Picker, Dialog, } from 'react-vant'
import { Image, NavBar, Toast } from '@nutui/nutui-react'
import '@nutui/nutui-react/dist/style.css'
import { Share, More, Cart, ArrowLeft, Close } from '@nutui/icons-react'
import { SideBar, NumberKeyboard, PasscodeInput, Space } from 'antd-mobile'
import { useState } from 'react'
import {post} from '../../../axios/request'
export default function Editphone() {
  let navigate=useNavigate()
   // 获取手机号
   let users = sessionStorage.getItem('users')
   let phone = ''
   if (users) {
     try {
       const userObj = JSON.parse(users)
       // console.log(userObj);
       phone = userObj.phone
       // console.log(phone);
       // 获取前三位添加4个*然后再添加手机号的后四位
       phone = `${phone.slice(0, 3)}****${phone.slice(7)}`
 
     } catch (error) {
       console.log('users为空');
 
     }
   }

   const edits=async()=>{

    const userObj = JSON.parse(users)
    // console.log(userObj);
    let phoneid = userObj.phone
    console.log(phoneid,'222');


    // let data=await post('/editpid',{phoneid})
    // console.log(data);
    // if(data.code==200){
      navigate('/setnewphone?phoneid='+phoneid)
    // }else{
    //   Toast.show('用户不存在')
    // }
    
    
   }
  return (
    <div id='editphone'>
      <div className="top">
        <NavBar
          style={{ backgroundColor: '#FFFFFF' }}
          back={
            <>
              <ArrowLeft />
              返回
            </>
          }
          onBackClick={() => { navigate(-1) }}
        >
          设置新手机号
        </NavBar>
        {/* <ArrowLeft></ArrowLeft> */}
      </div>
      <div className="cen">
        <p style={{ fontSize: '0.54rem', fontWeight: 'bold', textAlign: 'center', marginTop: '10px' }}>您当前正在使用的手机号为</p>
        <p style={{ textAlign: 'center', fontSize: '0.3667rem', marginTop: '10px', color: 'blue' }}>{phone}</p>
        <p style={{ fontSize: '0.3rem', textAlign: 'center', marginTop: '10px' }}>修改后您当前账号中的行程信息不变</p>
        <Button onClick={() => { edits() }} round nativeType='submit' style={{ backgroundColor: '#2D83FB', color: 'white', width: '8rem', marginLeft: '1.0667rem', marginTop: '0.2667rem' }} block>
          立即修改
        </Button>
      </div>
    </div>
  )
}
